$.views.converters({
    //扩展jsrender converters 参加 http://www.jsviews.com/#converters ,可以有多个参数
    //调用:{{subStrings:shopProductBrief lens=40}}   {{subStrings:brief}}
    //支持多参数和扩展属性
    //显示子串
    //搜索 $.views.converters
    "subStrings": function (str) {
        if (str == null || str == "") {
            return "";
        }
        var lens = this.tagCtx.props.lens
        if (typeof(lens) == undefined || typeof(lens) != 'number') {
            lens = 15;
        }
        if (str.length > lens) {
            return str.substring(0, lens) + "...";
        } else {
            return str;
        }
    },
    //{{splits:remark separators='^' indexs=5}}
    "splits": function (str) {
        if (str == null || str == "") {
            return "";
        }
        var index = this.tagCtx.props.indexs;//下标
        var separators = this.tagCtx.props.separators;//分割符号
        if (typeof(index) == undefined || typeof(index) != 'number') {
            index = 0;
        }
        if (typeof(separators) == undefined || separators == '') {
            separators = ",";
        }
        var strArr = str.split(separators);
        if (index > strArr.length - 1) {
            return str;
        } else {
            return strArr[index];
        }
    },
    //获取首图
    "firstImgs": function (str) {
        var arr = [];
        if (str == null || str == "" || typeof(str) != 'string') {
            str = "";
        }
        arr = str.split(",");
        if (arr.length > 0) {
            return arr[0];
        }
        return "";
    },
    //数字千位符格式化方法 {{toThousands:worksPrice}}
    "toThousands": function (n) {
        var num = Number(n);
        num = num.toFixed(2);
        n = num + "";
        var re = /\d{1,3}(?=(\d{3})+$)/g;
        var n1 = n.replace(/^(\d+)((\.\d+)?)$/, function (s, s1, s2) {
            return s1.replace(re, "$&,") + s2;
        });
        return n1;
    }
});
//初始化分页参数
var nextPage = 0;
var pageSize = 10;

/** 删除事件 */

function del(delurl) {
    var checkError = false;
    var delArray = [];
    $(".ckSelect").each(function () {
        var check = $(this).is(':checked');
        if (check) {
            var _id = $(this).attr("ckId");
            delArray.push(_id);
        }
    });
    if (delArray.length == 0) {
        myAlert("请选择要删除的项请选择");
        return;
    }
    myConfirm("你确定要删除选中项吗？", function () {
        var url = delurl + delArray.join(",");
        $.ajax({
            url: url,
            type: 'post',
            dataType: 'json',
            success: function (data) {
            	console.log(data.object)
                if (data.code == 1) {
                    dipscontent(getfilter(), contentUrl)
                    $("#_selectAll").attr("checked", false);
                } else {
                    myAlert(data.msg);
                }
            }
        });
    });
}
/** 锁定事件 */
function lock(lockurl) {
    var checkError = false;
    var delArray = [];
    $(".ckSelect").each(function () {
        var check = $(this).is(':checked');
        if (check) {
            var _id = $(this).attr("ckId");
            delArray.push(_id);
        }
    });
    if (delArray.length == 0) {
        myAlert("请选择要锁定的项");
        return;
    }
    myConfirm("你确定要锁定选中项吗？", function () {
        $.ajax({
            url: lockurl,
            type: 'post',
            data: {
                modelIds: delArray.join(","),
                status: -1
            },
            dataType: 'json',
            success: function (data) {
            	console.log(data.object)
                if (data.code == 1) {
                    dipscontent(getfilter(), contentUrl);
                    $("#_selectAll").attr("checked", false);
                } else {
                    myAlert(data.msg);
                }
            }
        });
    });
}
/** 上架事件 */
function lock1(lockurl) {
    var checkError = false;
    var delArray = [];
    $(".ckSelect").each(function () {
        var check = $(this).is(':checked');
        if (check) {
            var _id = $(this).attr("ckId");
            delArray.push(_id);
        }
    });
    if (delArray.length == 0) {
        myAlert("请选择要上架的项");
        return;
    }
    myConfirm("你确定要上架吗？", function () {
        $.ajax({
            url: lockurl,
            type: 'post',
            data: {
                modelIds: delArray.join(","),
                status: 2
            },
            dataType: 'json',
            success: function (data) {
            	console.log(data.object)
                if (data.code == 1) {
                    dipscontent(getfilter(), contentUrl);
                    $("#_selectAll").attr("checked", false);
                } else {
                    myAlert(data.msg);
                }
            }
        });
    });
}
/** 下架事件 */
function unlock1(unlockurl) {
    var checkError = false;
    var delArray = [];
    $(".ckSelect").each(function () {
        var check = $(this).is(':checked');
        if (check) {
            var _id = $(this).attr("ckId");
            delArray.push(_id);
        }
    });
    if (delArray.length == 0) {
        myAlert("请选择要下架的项");
        return;
    }
    myConfirm("你确定要下架吗？", function () {
        $.ajax({
            url: unlockurl,
            type: 'post',
            data: {
                modelIds: delArray.join(","),
                status: 1
            },
            dataType: 'json',
            success: function (data) {
            	console.log(data.object)
                if (data.code == 1) {
                    dipscontent(getfilter(), contentUrl);
                    $("#_selectAll").attr("checked", false);
                } else {
                    myAlert(data.msg);
                }
            }
        });
    });
}
/** 置顶事件 */
function toptime(topUrl) {
    var checkError = false;
    var delArray = [];
    $(".ckSelect").each(function () {
        var check = $(this).is(':checked');
        if (check) {
            var _id = $(this).attr("ckId");
            delArray.push(_id);
        }
    });
    if (delArray.length == 0) {
        myAlert("请选择要置顶的项");
        return;
    }
    myConfirm("你确定要置顶吗？", function () {
        $.ajax({
            url: topUrl,
            type: 'post',
            data: {
                modelIds: delArray.join(","),
                isTop: 1
            },
            dataType: 'json',
            success: function (data) {
            	console.log(data.object)
                if (data.code == 1) {
                    dipscontent(getfilter(), contentUrl);
                    $("#_selectAll").attr("checked", false);
                } else {
                    myAlert(data.msg);
                }
            }
        });
    });
}
/**取消 置顶事件 */
function canceltop(topUrl) {
    var checkError = false;
    var delArray = [];
    $(".ckSelect").each(function () {
        var check = $(this).is(':checked');
        if (check) {
            var _id = $(this).attr("ckId");
            delArray.push(_id);
        }
    });
    if (delArray.length == 0) {
        myAlert("请选择要取消置顶的项");
        return;
    }
    myConfirm("你确定要置顶吗？", function () {
        $.ajax({
            url: topUrl,
            type: 'post',
            data: {
                modelIds: delArray.join(","),
                isTop: 0
            },
            dataType: 'json',
            success: function (data) {
            	console.log(data.object)
                if (data.code == 1) {
                    dipscontent(getfilter(), contentUrl);
                    $("#_selectAll").attr("checked", false);
                } else {
                    myAlert(data.msg);
                }
            }
        });
    });
}
/** 同意审核事件 */
function agree(checkurl) {
    var checkError = false;
    var delArray = [];
    $(".ckSelect").each(function () {
        var check = $(this).is(':checked');
        if (check) {
            var a = $(this).parents('tr').find('td:eq(5)').html();
            if (a != "待审核") {
                return;
            }
            var _id = $(this).attr("ckId");
            delArray.push(_id);
        }
    });
    if (delArray.length == 0) {
        myAlert("请选择待审核的项");
        return;
    }
    if (delArray.length > 1) {
        myAlert("每次只能审核一项");
        return;
    }
    myConfirm("你确定要置顶吗？", function () {
        $.ajax({
            url: checkurl,
            type: 'post',
            data: {
                modelIds: delArray.join(","),
                checkStatus: 4,
                reason: null
            },
            dataType: 'json',
            success: function (data) {
            	console.log(data.object)
                if (data.code == 1) {
                    dipscontent(getfilter(), contentUrl);
                    $("#_selectAll").attr("checked", false);
                } else {
                    myAlert(data.msg);
                }
            }
        });
    });
}
/** 拒绝审核事件 */
function refuse(checkurl, buttomVal) {
    var checkError = false;
    var delArray = [];
    var cStatus = 3;
    $(".ckSelect").each(function () {
        var check = $(this).is(':checked');
        if (check) {
            var a = $(this).parents('tr').find('td:eq(5)').html();
            if (buttomVal == "拒绝") {
                if (a != "待审核") {
                    return;
                }
            } else if (buttomVal == "银联拒绝") {
                if (a != "审核中") {
                    return;
                }
                cStatus = 5;
            }
            var _id = $(this).attr("ckId");
            delArray.push(_id);
        }
    });
    if (delArray.length == 0) {
        if (buttomVal == "拒绝") {
            myAlert("请选择待审核的项");
            return;
        } else if (buttomVal == "银联拒绝") {
            myAlert("请选择审核中的项");
            return;
        }
    }
    if (delArray.length > 1) {
        myAlert("每次只能审核一项");
        return;
    }
    $("#createCountModal").modal();
    $("#sureAcount").click(function () {
        if ($("#refusereason").val()) {
            $("#sureAcount").addClass('disable_btn');
            $.ajax({
                url: checkurl,
                type: 'post',
                data: {
                    modelIds: delArray.join(","),
                    checkStatus: cStatus,
                    reason: $("#refusereason").val()
                },
                dataType: 'json',
                success: function (data) {
                	console.log(data.object)
                    if (data.code == 1) {
                        dipscontent(getfilter(), contentUrl);
                        window.location.reload();
                    } else {
                        myAlert(data.msg);
                    }
                }
            });
        } else {
            myAlert("未填写原因");
        }

    });
}

/** 启用事件 */
function unlock(unlockurl) {
    var checkError = false;
    var delArray = [];
    $(".ckSelect").each(function () {
        var check = $(this).is(':checked');
        if (check) {
            var _id = $(this).attr("ckId");
            delArray.push(_id);
        }
    });
    if (delArray.length == 0) {
        myAlert("请选择要启用的项");
        return;
    }
    myConfirm("你确定要启用吗？", function () {
        $.ajax({
            url: unlockurl,
            type: 'post',
            data: {
                modelIds: delArray.join(","),
                status: 1
            },
            dataType: 'json',
            success: function (data) {
            	console.log(data.object)
                if (data.code == 1) {
                    dipscontent(getfilter(), contentUrl);
                    $("#_selectAll").attr("checked", false);
                } else {
                    myAlert(data.msg);
                }
            }
        });
    });
}

/** 通过事件 */
function passState(unlockurl) {
    var checkError = false;
    var delArray = [];
    $(".ckSelect").each(function () {
        var check = $(this).is(':checked');
        if (check) {
            var _id = $(this).attr("ckId");
            delArray.push(_id);
        }
    });
    if (delArray.length == 0) {
        myAlert("请选择要通过的项");
        return;
    }
    myConfirm("你确定要通过吗？", function () {
        $.ajax({
            url: unlockurl,
            type: 'post',
            data: {
                modelIds: delArray.join(","),
                vSDC_State: 2
            },
            dataType: 'json',
            success: function (data) {
            	console.log(data)
                if (data.code == 1) {
                    dipscontent(getfilter(), contentUrl);
                    $("#_selectAll").attr("checked", false);
                } else {
                    myAlert(data.msg);
                }
            }
        });
    });
}

//推荐事件
function recommend(lockurl) {
    var checkError = false;
    var delArray = [];
    $(".ckSelect").each(function () {
        var check = $(this).is(':checked');
        if (check) {
            var _id = $(this).attr("ckId");
            delArray.push(_id);
        }
    });
    if (delArray.length == 0) {
        myAlert("请选择要推荐的项");
        return;
    }
    myConfirm("你确定要置顶吗？", function () {
        $.ajax({
            url: lockurl,
            type: 'post',
            data: {
                modelIds: delArray.join(","),
                isRecommend: 1
            },
            dataType: 'json',
            success: function (data) {
            	console.log(data)
                if (data.code == 1) {
                    dipscontent(getfilter(), contentUrl);
                    $("#_selectAll").attr("checked", false);
                } else {
                    myAlert(data.msg);
                }
            }
        });
    });
}
//取消推荐
function cancelRecommend(lockurl) {
    var checkError = false;
    var delArray = [];
    $(".ckSelect").each(function () {
        var check = $(this).is(':checked');
        if (check) {
            var _id = $(this).attr("ckId");
            delArray.push(_id);
        }
    });
    if (delArray.length == 0) {
        myAlert("请选择要取消推荐的项");
        return;
    }
    myConfirm("你确定要置顶吗？", function () {
        $.ajax({
            url: lockurl,
            type: 'post',
            data: {
                modelIds: delArray.join(","),
                isRecommend: 0
            },
            dataType: 'json',
            success: function (data) {
            	console.log(data)
                if (data.code == 1) {
                    dipscontent(getfilter(), contentUrl);
                    $("#_selectAll").attr("checked", false);
                } else {
                    myAlert(data.msg);
                }
            }
        });
    });
}

/** 加载内容 */
function dipscontent(jsonFilter, urls) {
    if (getUrlParam('nextPage')) {
        nextPage = getUrlParam('nextPage') - 1;
    }
    if ($("#_click_page").val() != undefined && $("#_click_page").val()) {
        nextPage = $("#_click_page").val();
    }
    if (typeof(nextPage) == 'undefined' || nextPage == "") {
        nextPage = 0;
        $("#_click_page").val(nextPage);
    }
    if (getUrlParam('pageSize')) {
        pageSize = getUrlParam('pageSize');
    }
    if ($("#selectPageSize").val() && $("#selectPageSize").val() != undefined) {
        pageSize = $("#selectPageSize").val();
    }
    if (typeof(pageSize) == 'undefined' || pageSize == "") {
        pageSize = 10;
        $("#selectPageSize").val(pageSize);
    }
    $.ajax({
        url: urls,
        dataType: 'json',
        type: 'POST',
        data: {
            jsonFilter: jsonFilter,
            nextPage: nextPage,
            pageSize: pageSize
        },
        success: function (data) {
        	console.log(data)
            if (data.code == 1) {
                var tblContentHtml = $("#tableContentTmple").render(data.object.content);
                $("#mycontent").html(tblContentHtml);
                //加载分页器
                loadTmpl.renderExternalTemplate("page", "#displayPage", data.object, 1);
                //活动页面加载时间日历
                $("#startTime").datetimepicker({
                    minView: "month",
                    format: 'yyyy-mm-dd',
                    language: 'zh-CN',
                    autoclose: true
                }).on('changeDate', function (ev) {
                    var starttime = $("#startTime").val();
                    $("#endTime").datetimepicker('setStartDate', starttime);
                    $("#startTime").datetimepicker('hide');
                });
                $("#endTime").datetimepicker({
                    minView: "month",
                    format: 'yyyy-mm-dd',
                    language: 'zh-CN',
                    autoclose: true
                }).on('changeDate', function (ev) {
                    var endtime = $("#endTime").val();
                    $("#startTime").datetimepicker('setEndDate', endtime);
                    $("#endTime").datetimepicker('hide');
                });

                $("#startTime1").datetimepicker({
                    minView: "month",
                    format: 'yyyy-mm-dd',
                    language: 'zh-CN',
                    autoclose: true
                }).on('changeDate', function (ev) {
                    var starttime = $("#startTime1").val();
                    $("#endTime1").datetimepicker('setStartDate', starttime);
                    $("#startTime1").datetimepicker('hide');
                });
                $("#endTime1").datetimepicker({
                    minView: "month",
                    format: 'yyyy-mm-dd',
                    language: 'zh-CN',
                    autoclose: true
                }).on('changeDate', function (ev) {
                    var endtime = $("#endTime1").val();
                    $("#startTime1").datetimepicker('setEndDate', endtime);
                    $("#endTime1").datetimepicker('hide');
                });


                //统计 statistic.jsp
                $("#search_year").datetimepicker({format: 'yyyy', startView : "decade", minView: 'decade',language : 'zh-CN',autoclose: true}).on('changeDate',function(ev){
                    var search_year=$("#search_year").val();
                    $("#search_year").datetimepicker('hide');
                });
            }
            else {
                myAlert(data.message || '数据加载失败，稍后重试！');
            }
        }
    });
}
function dipscontent1(jsonFilter, urls, search) {
    if (search == 1) {
        nextPage = 0;
    }
    /*if(getUrlParam('nextPage')){
     nextPage = getUrlParam('nextPage') - 1;
     }
     if($("#_click_page").val() != undefined && $("#_click_page").val()){
     nextPage = $("#_click_page").val();
     }*/
    if (typeof(nextPage) == 'undefined' || nextPage == "") {
        nextPage = 0;
        $("#_click_page").val(nextPage);
    }
    if (getUrlParam('pageSize')) {
        pageSize = getUrlParam('pageSize');
    }
    if ($("#selectPageSize").val() && $("#selectPageSize").val() != undefined) {
        pageSize = $("#selectPageSize").val();
    }
    if (typeof(pageSize) == 'undefined' || pageSize == "") {
        pageSize = 10;
        $("#selectPageSize").val(pageSize);
    }
    $.ajax({
        url: urls,
        dataType: 'json',
        type: 'POST',
        data: {
            jsonFilter: jsonFilter,
            nextPage: nextPage,
            pageSize: pageSize
        },
        success: function (data) {
            console.log(data);
            if (data.code == 1) {
                var tblContentHtml = $("#tableContentTmple").render(data.object.content);
                $("#mycontent").html(tblContentHtml);
                //加载分页器z
                loadTmpl.renderExternalTemplate("page", "#displayPage", data.object, 1);
                //活动页面加载时间日历
                $("#startTime").datetimepicker({
                    minView: "month",
                    format: 'yyyy-mm-dd',
                    language: 'zh-CN',
                    autoclose: true
                }).on('changeDate', function (ev) {
                    var starttime = $("#startTime").val();
                    $("#endTime").datetimepicker('setStartDate', starttime);
                    $("#startTime").datetimepicker('hide');
                });
                $("#endTime").datetimepicker({
                    minView: "month",
                    format: 'yyyy-mm-dd',
                    language: 'zh-CN',
                    autoclose: true
                }).on('changeDate', function (ev) {
                    var endtime = $("#endTime").val();
                    $("#startTime").datetimepicker('setEndDate', endtime);
                    $("#endTime").datetimepicker('hide');
                });
            }
            else {
                myAlert(data.message || '数据加载失败，稍后重试！');
            }
        }
    });
}
//查看详细
function findDetail(url) {
    var updateArray = [];
    var id;
    $(".ckSelect").each(function () {
        var check = $(this).is(':checked');
        if (check) {
            id = $(this).attr("ckId");
            updateArray.push(id);
        }
    });
    if (updateArray.length == 0) {
        myAlert("请选择要查看的项");
        return;
    }
    if (updateArray.length > 1) {
        myAlert("每次只能查看一项");
        return;
    }
    $.ajax({
        url: url,
        type: 'post',
        dataType: 'json',
        data: {
            modelId: id
        },
        success: function (data) {
            console.log(data);
            if (data.code == 1) {
                var tblContentHtml = $("#commentContentTmple").render(data.object);
                $(".detail").html(tblContentHtml);
            }
        }
    });
    $("#myModals").modal();
}

//查看详细
function findgoldDetail(url) {
    var updateArray = [];
    var id;
    $(".ckSelect").each(function () {
        var check = $(this).is(':checked');
        if (check) {
            id = $(this).attr("ckId");
            updateArray.push(id);
        }
    });
    if (updateArray.length == 0) {
        myAlert("请选择要查看的项");
        return;
    }
    if (updateArray.length > 1) {
        myAlert("每次只能查看一项");
        return;
    }
    $.ajax({
        url: url,
        type: 'post',
        dataType: 'json',
        data: {
            modelId: id
        },
        success: function (data) {
            console.log(data);
            if (data.code == 1) {
                var tblContentHtml = $("#commentContentTmple").render(data.object);
                $(".detail").html(tblContentHtml);
            }
        }
    });
    $("#myModals").modal();
}
//回车触发查询按钮
$(document).ready(function () {
    document.onkeydown = function (e) {
        var ev = document.all ? window.event : e;
        if (ev.keyCode == 13) {
            dipscontent1(getfilter(), contentUrl, 1)
        }
    }
    //表格列拖动以及行高亮选中
    $("#example2").resizableColumns({});
    $("#example2").tableGrid({
        checkAllId: "_selectAll",	//全选框的ID属性
        singleCheckboxClass: "ckSelect",
        selectRowClass: "warning",
        paging: "displayPage",
        pageAjax: function () {
            dipscontent(getfilter(), contentUrl);
        }
    });

    //点击查询按钮
    $("#search").click(function () {
        dipscontent1(getfilter(), contentUrl, 1);
    });

    //点击新增按钮
    $("#addSome").click(function () {
        location.href = editUrl + 0;
    });

    //点击修改按钮
    $("#updateSome").click(function () {
        var updateArray = [];
        $(".ckSelect").each(function () {
            var check = $(this).is(':checked');
            if (check) {
                var _id = $(this).attr("ckId");
                updateArray.push(_id);
            }
        });
        //判断优惠券是否使用
        var isUse = "";
        $(".ckSelect").each(function () {
            var check = $(this).is(':checked');
            if (check) {
                var _id = $(this).attr("ckUse");
                if (_id == 1) {
                    isUse = 1;
                }
            }
        });
        if (updateArray.length == 0) {
            myAlert("请选择要编辑的项");
            return;
        }
        if (updateArray.length > 1) {
            myAlert("每次只能编辑一项");
            return;
        }
        if (isUse == 1) {
            myAlert("优惠券已发放，不能编辑");
            return;
        }
        var from = window.location.href.split("?")[0] + "?nextPage=" + (parseInt($("#_click_page").val()) + 1) + "&pageSize=" + $("#selectPageSize").val();
        location.href = editUrl + updateArray[0] + '&from=' + from;
    });

    //点击删除按钮
    $("#deleteSome").click(function () {
        del(operateUrl + '?modelIds=');
    });

    //点击banner管理的新增按钮
    $("#addbannerSome").click(function () {
        var num = $("#mycontent").children().last().children().first().children().attr("data-id");
        if (num == 6) {
            myAlert("bannner图最多六张");
            return;
        }
        location.href = editUrl + 0;
    });

    //点击定投管理的新增按钮
    $("#regularbtn").click(function () {
        var num = $("#mycontent").children().last().children().first().children().attr("data-id");
        if (num == 1) {
            myAlert("只能添加一条数据");
            return;
        }
        location.href = editUrl + 0;
    });

    //点击锁定按钮
    $("#lockSome").click(function () {
        lock(operateUrl);
    });
    //下架
    $("#lockSome1").click(function () {
        unlock1(operateUrl);
    });
    //上架
    $("#openSome1").click(function () {
        lock1(operateUrl);
    });
    //置顶
    $("#topSome").click(function () {
        toptime(topUrl);
    });
    //取消置顶
    $("#cancelTop").click(function () {
        canceltop(topUrl);
    });
    //点击启用按钮
    $("#openSome").click(function () {
        unlock(operateUrl);
    });
    //点击通过(义工经历)
    $("#passSome").click(function () {
        passState(operateUrl_vSDC_State);
    });

    //同意审核
    $("#agreeSome").click(function () {
        agree(checkurl);
    });
    //拒绝审核
    $("#refuseSome").click(function () {
        refuse(checkurl, $("#refuseSome").val());
    });
    //拒绝审核
    $("#refuseSome1").click(function () {
        refuse(checkurl, $("#refuseSome1").val());
    });
    //清除时间
    $(".datetime_clear").click(function () {
        $(this).next().val('');
        if ($(this).next().attr('id') == 'startTime') {
            var starttime = $("#startTime").val();
            $("#endTime").datetimepicker('setStartDate', starttime);
            $("#startTime").datetimepicker('hide');
        }
        if ($(this).next().attr('id') == 'endTime') {
            var endtime = $("#endTime").val();
            $("#startTime").datetimepicker('setEndDate', endtime);
            $("#endTime").datetimepicker('hide');
        }
    });

    //点击发布按钮
    $("#announce").click(function () {
        var checkParams = $('input[class="ckSelect"]:checked');
        $.each(checkParams, function () {
            var a = $(this).parents('tr').find('td').last().html();
            if (a == "已发布") {
                return;
            }
        });
        check(url);
    });
    //点击推荐按钮
    $("#recommend").click(function () {
        var checkParams = $('input[class="ckSelect"]:checked');
        $.each(checkParams, function () {
            var a = $(this).parents('tr').find('td').last().html();
            if (a == "是") {
                return;
            }
            recommend(operateUrl);
        });

    });
    //点击取消推荐按钮
    $("#cancelRecommend").click(function () {
        var checkParams = $('input[class="ckSelect"]:checked');
        $.each(checkParams, function () {
            var a = $(this).parents('tr').find('td').last().html();
            if (a == "否") {
                return;
            }
            cancelRecommend(operateUrl);
        });

    });

    //分页点击事件
    $('#example2_paginate').find('a').click(function () {
        dipscontent(getfilter(), contentUrl);
    });
    //详细按钮
    $(document).on('click', '#detail', function () {
        findDetail(detailurl);
    });
    //详细按钮
    $(document).on('click', '#detailgold', function () {
        findgoldDetail(detailurl);
    });

    //反馈意见详细按钮
    $(document).on('click', '#feedBankDetail', function () {

        var updateArray = [];
        var id;
        var time;
        $(".ckSelect").each(function () {
            var check = $(this).is(':checked');
            if (check) {
                id = $(this).attr("ckId");
                updateArray.push(id);
                time = $(this).parents('tr').find('td').last().html();
            }
        });
        if (updateArray.length == 0) {
            myAlert("请选择要查看的项");
            return;
        }
        if (updateArray.length > 1) {
            myAlert("每次只能查看一项");
            return;
        }
        $.ajax({
            url: root + "cms/feedBack/findFeedBackById",
            type: 'post',
            dataType: 'json',
            data: {
                modelId: id,
                createTime: time
            },
            success: function (data) {
                console.log(data);
                if (data.code == 1) {
                    var urlStr = data.object.url;
                    if (!(imgs == undefined || imgs == null)) {
                        var imgs = urlStr.split(",");
                        data.object.urlImgs = imgs;
                    }
                    var tblContentHtml = $("#feedBackListDetailTmpl").render(data.object);
                    $("#feedBackListDetailTable").html(tblContentHtml);
                } else {
                }
            }
        });
        $("#myModals").modal();
    });

    //记事本详细按钮
    $(document).on('click', '#notepadDetail', function () {

        var updateArray = [];
        var id;
        var time;
        $(".ckSelect").each(function () {
            var check = $(this).is(':checked');
            if (check) {
                id = $(this).attr("ckId");
                updateArray.push(id);
                time = $(this).parents('tr').find('td').last().html();
            }
        });
        if (updateArray.length == 0) {
            myAlert("请选择要查看的项");
            return;
        }
        if (updateArray.length > 1) {
            myAlert("每次只能查看一项");
            return;
        }
        $.ajax({
            url: root + "cms/notepad/findNotepadById",
            type: 'post',
            dataType: 'json',
            data: {
                modelId: id,
                createTime: time
            },
            success: function (data) {
                console.log(data);
                if (data.code == 1) {
                    var urlStr = data.object.url;

                    var tblContentHtml = $("#notepadListDetailTmpl").render(data.object);
                    $("#notepadListDetailTable").html(tblContentHtml);
                } else {
                }
            }
        });
        $("#myModals").modal();
    });

    //心愿单详细按钮
    $(document).on('click', '#wishDetail', function () {

        var updateArray = [];
        var id;
        var time;
        $(".ckSelect").each(function () {
            var check = $(this).is(':checked');
            if (check) {
                id = $(this).attr("ckId");
                updateArray.push(id);
                time = $(this).parents('tr').find('td').last().html();
            }
        });
        if (updateArray.length == 0) {
            myAlert("请选择要查看的项");
            return;
        }
        if (updateArray.length > 1) {
            myAlert("每次只能查看一项");
            return;
        }
        $.ajax({
            url: root + "cms/wish/findWishById",
            type: 'post',
            dataType: 'json',
            data: {
                modelId: id,
                createTime: time
            },
            success: function (data) {
                console.log(data);
                if (data.code == 1) {
                    var urlStr = data.object.url;

                    var tblContentHtml = $("#wishDetailTmpl").render(data.object);
                    $("#wishDetailTable").html(tblContentHtml);
                } else {
                }
            }
        });
        $("#myModals").modal();
    });
    //朋友圈详细按钮
    $(document).on('click', '#momentsDetail', function () {

        var updateArray = [];
        var id;
        var time;
        $(".ckSelect").each(function () {
            var check = $(this).is(':checked');
            if (check) {
                id = $(this).attr("ckId");
                updateArray.push(id);
                time = $(this).parents('tr').find('td').last().html();
            }
        });
        if (updateArray.length == 0) {
            myAlert("请选择要查看的项");
            return;
        }
        if (updateArray.length > 1) {
            myAlert("每次只能查看一项");
            return;
        }
        $.ajax({
            url: root + "cms/moments/findMomentsInteractionByMomentsId",
            type: 'post',
            dataType: 'json',
            data: {
                modelId: id,
                createTime: time
            },
            success: function (data) {
                console.log(data);

                if (data) {
                    var tblContentHtml = $("#momentsDetailTmpl").render(data);
                    $("#momentsDetailTable").html(tblContentHtml);

                }
            }
        });
        $("#myModals").modal();
    });

});


//除法
function accDiv(arg1, arg2) {
    var t1 = 0, t2 = 0, r1, r2;
    try {
        t1 = arg1.toString().split(".")[1].length
    } catch (e) {
    }
    try {
        t2 = arg2.toString().split(".")[1].length
    } catch (e) {
    }
    with (Math) {
        r1 = Number(arg1.toString().replace(".", ""))
        r2 = Number(arg2.toString().replace(".", ""))
        return (r1 / r2) * pow(10, t2 - t1);
    }
}